package com.example.teacher

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.teacher.adapter.ListAdapter
import com.example.teacher.data.Attendance
import com.example.teacher.databinding.ActivityListBinding
import com.example.teacher.util.JsonUtil

class ListActivity : AppCompatActivity() {
    private lateinit var databind:ActivityListBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        databind=DataBindingUtil.setContentView(this,R.layout.activity_list)

        //获取数据
        val res = intent.getStringExtra("data")
        val resultData=JsonUtil.DataParse<Attendance>(res)
        val data= ArrayList<Attendance>()

        for(i in resultData.indices){
            data.add(resultData[i])
        }

        val adapter:ListAdapter=ListAdapter(data)

        databind.recyclerView.layoutManager=LinearLayoutManager(this)
        databind.recyclerView.adapter=adapter
    }
}